]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ibusManager: Make more resilient to completion/engine independent changes
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 17 Oct 2022 13:55:11 +0000 (15:55 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 26 Oct 2022 10:00:37 +0000 (10:00 +0000)
Besides user interaction, there's two users of IBusManager.setEngine():

- The code that toggles all IBus engines off on entries with PASSWORD
  purpose.
- The code that toggles completion support on OSK presence.

These are currently pretty oblivious to each other. Make this
interaction more resilient by making all external IBusManager changes
more cautious about directly changing the engine, and revoke properly
the completion mode if it needs be (e.g. changing to a non-XKB engine).

But another notable change is that ibus-typing-booster is now preferred
always, over PASSWORD purpose hints. This is done to avoid possible
doubled attempts to change the current engine (and ensuing IBusInputContext
confusion).

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2512>

js/misc/ibusManager.js

index 5ba7e636d0f5528690498de1d8e6d0f69938223a..820ee827cf3e61c88face9407e72347072a36784 100644 (file)
@@ -288,7 +288,7 @@ var IBusManager = class extends Signals.EventEmitter {
         return this._engines.get(id);
     }
 
-    async setEngine(id, callback) {
+    async _setEngine(id, callback) {
         // Send id even if id == this._currentEngineName
         // because 'properties-registered' signal can be emitted
         // while this._ibusSources == null on a lock screen.
@@ -306,10 +306,25 @@ var IBusManager = class extends Signals.EventEmitter {
             if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
                 logError(e);
         }
+
         if (callback)
             callback();
     }
 
+    async setEngine(id, callback) {
+        if (this._preOskState)
+            this._preOskState.engine = id;
+
+        const isXkb = id.startsWith('xkb:');
+        if (this._oskCompletion && isXkb)
+            return;
+
+        if (this._oskCompletion)
+            this.setCompletionEnabled(false, callback);
+        else
+            await this._setEngine(id, callback);
+    }
+
     preloadEngines(ids) {
         if (!this._ibus || !this._ready)
             return;
@@ -339,7 +354,7 @@ var IBusManager = class extends Signals.EventEmitter {
 
     setCompletionEnabled(enabled, callback) {
         /* Needs typing-booster available */
-        if (!this._engines.has(TYPING_BOOSTER_ENGINE))
+        if (enabled && !this._engines.has(TYPING_BOOSTER_ENGINE))
             return false;
         /* Can do only on xkb engines */
         if (enabled && !this._currentEngineName.startsWith('xkb:'))
@@ -373,12 +388,12 @@ var IBusManager = class extends Signals.EventEmitter {
 
             settings.reset(KEY_INLINECOMPLETION);
             settings.set_string(KEY_INPUTMETHOD, 'NoIME');
-            this.setEngine(TYPING_BOOSTER_ENGINE, callback);
+            this._setEngine(TYPING_BOOSTER_ENGINE, callback);
         } else if (this._preOskState) {
             const {engine, emoji, langs, completion, inputMethod} =
                   this._preOskState;
             this._preOskState = null;
-            this.setEngine(engine, callback);
+            this._setEngine(engine, callback);
             settings.set_value(KEY_EMOJIPREDICTIONS, emoji);
             settings.set_value(KEY_DICTIONARY, langs);
             settings.set_value(KEY_INLINECOMPLETION, completion);